<template>
  <div class="previewPage" @click="e=>e.stopPropagation()" v-if="showPage"> 
    <div class="previewHead" :style="{'height':topHeight+'px','padding-top':statusBar+'px'}">
      <div class="leftIcon" @click="backTo">
        <text class="arricon">&#xe603;</text>
      </div>
      <text class="centenTx">{{currentI+1}}/{{imageList.length}}</text>
      <div class="leftIcon"></div>
    </div>
    <!-- 预览图片 -->
    <div style="flex:1">
      <slider class="slider" interval="3000" :index="currentI" @change="preveiewChage">
        <scroller
          class="frame"
          v-for="(img,index) in imageList"
          :key="index"
          :style="{'height':imgHeight+'px'}"
        > 
          <ImgAuto :width="750" :imgSrc="img" />
        </scroller>
      </slider>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      showPage: false,
      imgHeight: "",
      statusBar: "",
      topHeight: "",
      currentI: 0,
      posterIn: 0,
      imageList: []
    };
  },
  created() {
    this.statusBar = this.getStatusHeight();
    this.topHeight = this.statusBar - 0 + 80;
    this.imgHeight = this.getScreenHeight() - this.topHeight;
  },
  methods: {
    initPage(list, id, index) {
      this.imageList = list;
      // this.posterIn = index;
      this.currentI = id;
      this.showPage = true;
    },
    preveiewChage(data) {
      this.currentI = data.index;
    },
    removeImg() {
      this.imageList.splice(this.currentI, 1);
      this.$emit("removePhoto", this.currentI);
    },
    changPoste() {
      this.posterIn = this.currentI;
      this.$emit("changPoster", this.currentI);
    },
    hidePage() {
      this.showPage = false;
    },

    backTo() {
      this.$emit("hidePreview");
    }
  }
};
</script>

<style>
.previewHead {
  background-color: #303030;
  flex-direction: row;
}
.previewPage {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  right: 0;
  background-color: #fff;
}
.slider {
  flex: 1;
  width: 750px;
  background-color: #eee;
}
.frame {
  width: 750px; 
  justify-content: center;
  align-items: center; 
}
.image {
  width: 750px;
}
.previewBottom {
  width: 750px;
  flex-direction: row;
  align-items: center;
  padding: 0 32px;
  justify-content: space-around;
}
.setPost {
  height: 80px;
  padding: 0 40px;
  line-height: 80px;
  border-radius: 10px;
  background-color: #303030;
  color: #fff;
  text-align: center;
  font-size: 30px;
}
.setPost:active {
  background-color: #222;
}
.notClick {
  height: 80px;
  padding: 0 60px;
  line-height: 80px;
  border-radius: 10px;
  background-color: #f5f5f5;
  color: #303030;
  text-align: center;
  font-size: 30px;
}
.leftIcon {
  justify-content: flex-start;
  align-items: center;
  flex-direction: row;
  padding-left: 26px;
  padding-right: 26px;
  height: 80px;
  width: 120px;
}
.centenTx {
  line-height: 80px;
  color: #fff;
  text-align: center;
  flex: 1;
  font-size: 42px;
}
.leftIcon:active {
  color: #eeeeee;
  background-color: #222222;
}
.arricon {
  font-size: 40px;
  font-family: iconfont;
  color: #ffffff;
}
</style>